﻿<%@ Control Language="C#" AutoEventWireup="true" CodeBehind="TransactionUC.ascx.cs" Inherits="ERP.PageUC.TransactionUC" %>
<%@ Register Src="~/PageUC/CustomerUC.ascx" TagPrefix="uc1" TagName="CustomerUC" %>
<%@ Register Src="~/PageUC/DestinationUC.ascx" TagPrefix="uc1" TagName="DestinationUC" %>
<%@ Register Src="~/PageUC/MethodUC.ascx" TagPrefix="uc1" TagName="MethodUC" %>
<script>
    function setSelected(selectObj, valueToSet) {
        for (var i = 0; i < selectObj.options.length; i++) {
            if (selectObj.options[i].value == valueToSet) {
                selectObj.options[i].selected = true;
                return;
            }
        }
    }
    function DetailRows(x) {
        //gets table
        var getTable = document.getElementById('MyTableTransaction');
        //gets cells of current row  
        var getCells = getTable.rows.item(x.rowIndex).cells;

        document.getElementById('<%=lbID.ClientID %>').value = getCells.item(0).innerHTML;
        document.getElementById('<%=txtMaGiaoDich.ClientID %>').disabled = true;
        document.getElementById('<%=txtMaGiaoDich.ClientID %>').value = getCells.item(2).innerHTML;
        setSelected(document.getElementById('<%=drKhachHang.ClientID %>'), getCells.item(3).innerHTML);
        document.getElementById('<%=txtTenKhachHang.ClientID %>').value = getCells.item(5).innerHTML;
        document.getElementById('<%=txtThoiGian.ClientID %>').value = getCells.item(4).innerHTML;
        setSelected(document.getElementById('<%=drMucDich.ClientID %>'), getCells.item(6).innerHTML);
        setSelected(document.getElementById('<%=drPhuongThuc.ClientID %>'), getCells.item(7).innerHTML);
        document.getElementById('<%=txtNoiDung.ClientID %>').value = getCells.item(8).innerHTML;
        document.getElementById('<%=txtKetQua.ClientID %>').value = getCells.item(9).innerHTML;
        document.getElementById('<%=txtGhiChu.ClientID %>').value = getCells.item(10).innerHTML;
        document.getElementById('<%=rdbSanPhamDangDung.ClientID %>').checked = getCells.item(11).innerHTML == "True" ? true : false;
        document.getElementById('<%=txtSanPhamDangDung.ClientID %>').value = getCells.item(12).innerHTML;
        document.getElementById('<%=rdbChuaCoNhuCau.ClientID %>').checked = getCells.item(13).innerHTML == "True" ? true : false;
        document.getElementById('<%=txtChuaCoNhuCau.ClientID %>').value = getCells.item(14).innerHTML;
        document.getElementById('<%=rdbLienHeLaiSau.ClientID %>').checked = getCells.item(15).innerHTML == "True" ? true : false;
        document.getElementById('<%=txtLienHeLaiSau.ClientID %>').value = getCells.item(16).innerHTML;
        document.getElementById('<%=rdbLichHenLamViec.ClientID %>').checked = getCells.item(17).innerHTML == "True" ? true : false;
        document.getElementById('<%=txtLichHenLamViec.ClientID %>').value = getCells.item(18).innerHTML;
        document.getElementById('<%=rdbDoiTuongCoTiemNang.ClientID %>').checked = getCells.item(19).innerHTML == "True" ? true : false;
        document.getElementById('<%=rdbChuaXacDinh.ClientID %>').checked = getCells.item(20).innerHTML == "True" ? true : false;
        document.getElementById('<%=rdbKhongCoTiemNang.ClientID %>').checked = getCells.item(21).innerHTML == "True" ? true : false;

        $("#giaodich").dialog("open");
    }
    function CheckSaveTransaction() {
        var emailRegex = /^[a-zA-Z0-9.!#$%&'*+\/=?^_`{|}~-]+@[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)*$/;
        var kt1 = $('#<%=txtMaGiaoDich.ClientID %>');
        var kt2 = $('#<%=drKhachHang.ClientID %>');
        var kt3 = $('#<%=drMucDich.ClientID %>');
        var kt4 = $('#<%=drPhuongThuc.ClientID %>');
        var allFields = $([]).add(kt1).add(kt2).add(kt3).add(kt4);
        var valid;
        allFields.removeClass("ui-state-error");
        valid = checkLength(kt1, "Số giao dịch", 1, 50);
        valid = valid && checkdr(kt2, "khách hàng");
        valid = valid && checkdr(kt3, "mục đích");
        valid = valid && checkdr(kt4, "phương thức");
        if (valid) {
            updateTips('');
            allFields.removeClass("ui-state-error");
        }
        return valid;
    };
</script>
<asp:UpdatePanel ID="upDateAll" runat="server">
    <ContentTemplate>
        <!---------------Toolbar---------------->
        <div class="toolbar-main">
            <asp:LinkButton id="btnAdd" CssClass="btn btn-default btn-sm" title="Thêm mới" runat="server" OnClick="btnAdd_Click"><span class="glyphicon glyphicon-pencil"></span>Thêm mới</asp:LinkButton>
            <asp:LinkButton ID="btnDelete" CssClass="btn btn-default btn-sm" title="Xóa" runat="server" OnClientClick="return confirmCheckIn(this)" OnClick="btnDelete_Click"><span class="glyphicon glyphicon-trash"></span> Xoá</asp:LinkButton>
            <asp:LinkButton ID="btnExcel" CssClass="btn btn-default btn-sm" title="Xuất file Excel" runat="server"><span class="glyphicon glyphicon-print"></span> Xuất file Excel</asp:LinkButton>
        </div>
        <!---------------Toolbar---------------->
        <%=StrAlert %>
        <!----------------Loading---------------->
        <asp:UpdateProgress ID="upDateProcess" runat="server" AssociatedUpdatePanelID="upDateAll">
            <ProgressTemplate>
                <span style="text-align: center" class="label label-warning">Đang tải...</span>
            </ProgressTemplate>
        </asp:UpdateProgress>
        <!--------------Kêt-thúc----------------->
        <!-------------Hiễn-Dữ-Liệu-------------->
        <div class="table-responsive">
            <asp:ListView ID="ListViewAll" runat="server" DataKeyNames="Transaction_Id" OnItemCommand="ListViewAll_ItemCommand">
                <LayoutTemplate>
                    <table id="MyTableTransaction" class="tablesorter">
                        <thead>
                            <tr>
                                <th style="text-align: center" data-sorter="false" data-filter="false">STT</th>
                                <th style="text-align: center" data-sorter="false" data-filter="false">
                                    <input type="checkbox" onchange="checkAll()" id="chkAll" />
                                </th>
                                <th style="text-align: center" class="filter-select" data-placeholder="--Chọn số giao dịch--">Số Giao Dịch</th>
                                <th style="text-align: center">Ngày Giờ Giao Dịch</th>
                                <th style="text-align: center" class="filter-select" data-placeholder="--Chọn số giao dịch--">Khách Hàng</th>
                            </tr>
                        </thead>
                        <tbody>
                            <tr id="itemPlaceholder" runat="server">
                            </tr>
                        </tbody>
                    </table>
                </LayoutTemplate>
                <ItemTemplate>
                    <tr runat="server" ondblclick="EditRows($(this))" class="warning">
                        <td style="text-align: center"><%# Eval("Transaction_Id") %></td>
                        <td style="text-align: center">
                            <asp:CheckBox ClientIDMode="Static" ID="chkList" runat="server" />
                        </td>
                        <td><%# Eval("Transaction_No") %></td>
                        <td style="display: none"><%# Eval("Customer_ID") %></td>
                        <td><%# Eval("Transaction_Date") %></td>
                        <td><%# Eval("Customer_Name") %></td>
                        <td style="display: none"><%# Eval("Destination_ID") %></td>
                        <td style="display: none"><%# Eval("Method_ID") %></td>
                        <td style="display: none"><%# Eval("Transaction_Content") %></td>
                        <td style="display: none"><%# Eval("Transaction_Result") %></td>
                        <td style="display: none"><%# Eval("Transaction_Note") %></td>
                        <td style="display: none"><%# Eval("Transaction_Available") %></td>
                        <td style="display: none"><%# Eval("Transaction_Available_Content") %></td>
                        <td style="display: none"><%# Eval("Transaction_NotAvailable") %></td>
                        <td style="display: none"><%# Eval("Transaction_NotAvailable_Content") %></td>
                        <td style="display: none"><%# Eval("Transaction_Contact_Again") %></td>
                        <td style="display: none"><%# Eval("Transaction_Contact_Again_Content") %></td>
                        <td style="display: none"><%# Eval("Transaction_Schedule") %></td>
                        <td style="display: none"><%# Eval("Transaction_Schedule_ID") %></td>
                        <td style="display: none"><%# Eval("Transaction_Potential") %></td>
                        <td style="display: none"><%# Eval("Transaction_Unknown") %></td>
                        <td style="display: none"><%# Eval("Transaction_NotPotential") %></td>
                        <td style="text-align: center; display:none;">
                                <asp:Label ID="lbIDDetail" runat ="server" Text='<%# Eval("Transaction_Id") %>'></asp:Label>
                                    <asp:Button ID="Detail" CssClass="btn btn-default btn-sm btn-xs editclick" runat="server" Text="Thay đổi" CommandName="_ViewDetail"/>
                                </td>
                    </tr>
                </ItemTemplate>
                <EmptyDataTemplate>
                    <div class='alert alert-danger'>
                        <a href='#' class='close' data-dismiss='alert'>&times;</a>
                        Không tìm thấy mẫu tin nào !
                    </div>

                </EmptyDataTemplate>
            </asp:ListView>
        </div>
        <div class="pager pagerMyTableTransaction">
            <div class="toolbar-main">
                <asp:LinkButton ID="btnReload" CssClass="btn btn-default btn-xs glyphicon glyphicon glyphicon-retweet" title="Tải lại" runat="server" OnClick="btnReload_Click"></asp:LinkButton>
                &nbsp;
                    <asp:TextBox ID="txtSearch" CssClass="textbox-search" runat="server" />
                <asp:LinkButton ID="btnSearch" CssClass="btn btn-default btn-xs glyphicon glyphicon glyphicon-search" title="Tìm kiếm" runat="server" OnClick="btnSearch_Click"></asp:LinkButton>
                &nbsp;             
                    <span>Trang</span>
                <select class="gotoPage" title="Select page number"></select>
                <img src="../Content/TableSort/addons/pager/icons/first.png" class="first" alt="First" />
                <img src="../Content/TableSort/addons/pager/icons/prev.png" class="prev" alt="Prev" />
                <span class="pagedisplay"></span>
                <img src="../Content/TableSort/addons/pager/icons/next.png" class="next" alt="Next" />
                <img src="../Content/TableSort/addons/pager/icons/last.png" class="last" alt="Last" />
            </div>
        </div>
    </ContentTemplate>
    <Triggers>
        <asp:AsyncPostBackTrigger ControlID="btnDelete" EventName="Click" />
        <asp:AsyncPostBackTrigger ControlID="btnSearch" EventName="Click" />
        <asp:AsyncPostBackTrigger ControlID="btnReload" EventName="Click" />
    </Triggers>
</asp:UpdatePanel>
<div id="giaodich" title="Cập nhật giao dịch">
    <asp:UpdatePanel ID="upNewUpdatePanel" UpdateMode="Conditional" ChildrenAsTriggers="true" runat="server">
        <ContentTemplate>
            <div class="btn-toolbar">
                <asp:LinkButton ID="btnSavePopup" data-placement="bottom" class="btn btn-default btn-sm" title="Lưu lại" runat="server" OnClientClick="return CheckSaveTransaction();" OnClick="btnSavePopup_Click"><span class="glyphicon glyphicon-floppy-disk"></span> Lưu lại</asp:LinkButton>
                &nbsp;
            <asp:LinkButton ID="btnReloadPopup" data-placement="bottom" class="btn btn-default btn-sm" title="Tải lại" runat="server" OnClick="btnReloadPopup_Click"><span class="glyphicon glyphicon-retweet"></span> Tải lại</asp:LinkButton>
                &nbsp;
            <input type="hidden" id="lbID" runat="server" /><label class="validateTips"></label>
                <asp:UpdateProgress ID="upDateProcessUC" runat="server" AssociatedUpdatePanelID="upNewUpdatePanel">
                    <ProgressTemplate>
                        <span class="label label-warning">Đang tải..</span>
                    </ProgressTemplate>
                </asp:UpdateProgress>
            </div>
            <div class="ui-main" style="width: 925px">
                <div class="ui-box">
                    <label class="labelpopup" style="width: 100px">Số giao dịch :</label>
                    <asp:TextBox ID="txtMaGiaoDich" CssClass="textbox_child_text" runat="server" data-allow="add"></asp:TextBox>
                    &nbsp;&nbsp;
                <label class="labelpopup" style="width: 100px">Mã khách hàng</label>
                    <asp:DropDownList ID="drKhachHang" Style="width: 155px" CssClass="textbox_child_text" runat="server" AppendDataBoundItems="True" AutoPostBack="True" OnSelectedIndexChanged="drKhachHang_SelectedIndexChanged"></asp:DropDownList>
                    <a class="relationlink" onclick="return Show('#giaodich_themkhachhang');">...</a>
                    &nbsp;&nbsp;
                <label class="labelpopup" style="width: 120px">Tên khách hàng : </label>
                    <asp:TextBox ID="txtTenKhachHang" Style="width: 155px" CssClass="textbox_child_text" runat="server" Enabled="False"></asp:TextBox>
                </div>
                <div class="ui-box">
                    <label class="labelpopup" style="width: 100px">Thời gian : </label>
                    <asp:TextBox ID="txtThoiGian" CssClass="textbox_child_text_ngay_thoigian" runat="server"></asp:TextBox>
                    <label class="labelpopup" style="width: 99px">Địa chỉ : </label>
                    <asp:TextBox ID="txtDiaChi" Style="width: 472px" CssClass="textbox_child_text" runat="server"></asp:TextBox>
                </div>
                <div class="ui-box">
                    <label class="labelpopup" style="width: 100px">Mã số thuế : </label>
                    <asp:TextBox ID="txtMaSoThue" CssClass="textbox_child_text" runat="server"></asp:TextBox>
                    &nbsp;&nbsp;
                <label class="labelpopup" style="width: 100px">Ông / Bà : </label>
                    <asp:TextBox ID="txtLienhe" CssClass="textbox_child_text" runat="server"></asp:TextBox>
                    &nbsp;&nbsp;
                <label class="labelpopup" style="width: 120px">Chức vụ : </label>
                    <asp:TextBox ID="txtChucVu" Style="width: 155px" CssClass="textbox_child_text" runat="server" Enabled="False"></asp:TextBox>
                </div>
                <div class="Check3">
                    Nội dung giao dịch
                </div>
                <div class="ChildCheck3">
                    <div class="ui-box">
                        <label class="labelpopup" style="width: 100px">Mục đích : </label>
                        <asp:DropDownList ID="drMucDich" Style="width: 155px" CssClass="textbox_child_text" runat="server" AppendDataBoundItems="True"></asp:DropDownList>
                        <a class="relationlink" onclick="return Show('#giaodich_themmucdich');">...</a>
                        &nbsp;&nbsp;
                <label class="labelpopup" style="width: 100px">Phương thức : </label>
                        <asp:DropDownList ID="drPhuongThuc" Style="width: 147px" CssClass="textbox_child_text" runat="server" AppendDataBoundItems="True"></asp:DropDownList>
                        <a class="relationlink" onclick="return Show('#giaodich_themphuongthuc');">...</a>
                    </div>
                    <div class="ui-box">
                        <label class="labelpopup" style="width: 100px;">Nội dung : </label>
                        <asp:TextBox ID="txtNoiDung" TextMode="MultiLine" Style="width: 778px; height: 50px;" CssClass="textbox-muiti" runat="server"></asp:TextBox>
                    </div>
                    <div class="ui-box">
                        <label class="labelpopup" style="width: 100px">Kết quả : </label>
                        <asp:TextBox ID="txtKetQua" TextMode="MultiLine" Style="width: 778px; height: 50px;" CssClass="textbox-muiti" runat="server"></asp:TextBox>
                    </div>
                    <div class="ui-box">
                        <label class="labelpopup" style="width: 100px">Ghi chú : </label>
                        <asp:TextBox ID="txtGhiChu" TextMode="MultiLine" Style="width: 778px; height: 50px;" CssClass="textbox-muiti" runat="server"></asp:TextBox>
                    </div>
                </div>
                <div class="Check2">
                    Đánh giá chung
                </div>
                <div class="ChildCheck2">
                    <div class="ui-box" style="width: 540px; float: left">
                        <asp:RadioButton ID="rdbSanPhamDangDung" runat="server" GroupName="DanhGia" />
                        <label class="labelpopup" style="width: 140px">Sản phẩm đang dùng </label>
                        <asp:TextBox ID="txtSanPhamDangDung" CssClass="textbox-muiti" runat="server" Enabled="False"></asp:TextBox>
                    </div>
                    <div class="ui-main" style="float: right; margin-right: 40px;">
                        <div class="ui-box" style="width: 240px;">
                            <asp:RadioButton ID="rdbDoiTuongCoTiemNang" runat="server" GroupName="DanhGiaDoiTuong" />
                            <label class="labelpopup" style="width: 215px"><span style="color: blue">Đối tượng có tiềm năng </span></label>
                        </div>
                        <div class="ui-box" style="width: 240px;">
                            <asp:RadioButton ID="rdbChuaXacDinh" runat="server" GroupName="DanhGiaDoiTuong" />
                            <label class="labelpopup" style="width: 215px">Chưa xác định </label>
                        </div>
                        <div class="ui-box" style="width: 240px;">
                            <asp:RadioButton ID="rdbKhongCoTiemNang" runat="server" GroupName="DanhGiaDoiTuong" />
                            <label class="labelpopup" style="width: 215px"><span style="color: Red">Đối tượng không có tiềm năng</span> </label>
                        </div>
                    </div>
                    <div class="ui-box" style="width: 540px; float: left">
                        <asp:RadioButton ID="rdbChuaCoNhuCau" runat="server" GroupName="DanhGia" />
                        <label class="labelpopup" style="width: 140px">Chưa có nhu cầu </label>
                        <asp:TextBox ID="txtChuaCoNhuCau" CssClass="textbox-muiti" runat="server" Enabled="False"></asp:TextBox>
                    </div>
                    <div class="ui-box" style="width: 540px; float: left">
                        <asp:RadioButton ID="rdbLienHeLaiSau" runat="server" GroupName="DanhGia" />
                        <label class="labelpopup" style="width: 140px">Liên hệ lại sau </label>
                        <asp:TextBox ID="txtLienHeLaiSau" CssClass="textbox-muiti" runat="server" Enabled="False"></asp:TextBox>
                    </div>
                    <div class="ui-box" style="display: none; width: 540px; float: left">
                        <asp:RadioButton ID="rdbLichHenLamViec" runat="server" GroupName="DanhGia" />
                        <label class="labelpopup" style="width: 140px">Lịch Hẹn Làm Việc </label>
                        <asp:TextBox ID="txtLichHenLamViec" CssClass="textbox-muiti" runat="server" Enabled="False"></asp:TextBox>
                    </div>
                </div>
            </div>
        </ContentTemplate>
        <Triggers>
            <asp:AsyncPostBackTrigger ControlID="btnSavePopup" EventName="Click" />
        </Triggers>
    </asp:UpdatePanel>
</div>
